<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 全 0 子数组的数目 -->
    <script>
      var fn = function (nums) {
        let total = 0
        let cur = 0
        for (let i = 0; i < nums.length; i++) {
          if (nums[i] === 0) {
            cur++
            total += cur
          } else {
            cur = 0
          }
        }
        return total
      }
      console.log(fn([1, 3, 0, 0, 2, 0, 0, 4]))
    </script>
  </body>
</html>
